﻿using System;
using System.Data;
using System.Linq;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        private void JLTCOSTLIST(DataSet db)
        {
            /*
FACTORY	CURRENCY	VKPART	VAABEZ	CONSTRUCTION	COLOR	INVDAT	INVOICE	WARPDEN	WEFTDEN	WEFTTOT	MDELQTY	YARNVALUE	
                DYEVALUE	MCOSTFIN	MCOSTPAKVV	OTHER	MCOSTUNIT	PRODVALUE	OTHERSVALUE	COSTUNIT	RMBPRICE	TOTCOST	RMBVALUE	
                MCOSTNET	COSTTOT	COSTTOTW	ACTCOST	ACTTOTCOST	ACTTOTCOSTW	KDKNAME	TOTYARN	TOTDYE	TOTFIN	TOTPAKVV	TOTOTHER
*/
            try
            {
                DataTable dtSoruce = db.Tables["ICC_VKCOST"];
                DataTable dtOutput = new DataTable();
                dtOutput.Columns.Add("FACTORY", typeof(System.String));
                dtOutput.Columns.Add("CURRENCY", typeof(System.String));
                dtOutput.Columns.Add("VKPART", typeof(System.String));
                dtOutput.Columns.Add("VAABEZ", typeof(System.String));
                dtOutput.Columns.Add("CONSTRUCTION", typeof(System.String));
                dtOutput.Columns.Add("COLOR", typeof(System.String));
                dtOutput.Columns.Add("INVDAT", typeof(System.String));
                dtOutput.Columns.Add("INVOICE", typeof(System.String));
                dtOutput.Columns.Add("WARPDEN", typeof(System.String));
                dtOutput.Columns.Add("WEFTDEN", typeof(System.String));
                dtOutput.Columns.Add("WEFTTOT", typeof(System.String));
                dtOutput.Columns.Add("MDELQTY", typeof(System.String));
                dtOutput.Columns.Add("YARNVALUE", typeof(System.String));
                dtOutput.Columns.Add("DYEVALUE", typeof(System.String));
                dtOutput.Columns.Add("MCOSTFIN", typeof(System.String));
                dtOutput.Columns.Add("MCOSTPAKVV", typeof(System.String));
                dtOutput.Columns.Add("OTHER", typeof(System.String));
                dtOutput.Columns.Add("MCOSTUNIT", typeof(System.String));
                dtOutput.Columns.Add("PRODVALUE", typeof(System.String));
                dtOutput.Columns.Add("OTHERSVALUE", typeof(System.String));
                dtOutput.Columns.Add("COSTUNIT", typeof(System.String));
                dtOutput.Columns.Add("RMBPRICE", typeof(System.String));
                dtOutput.Columns.Add("TOTCOST", typeof(System.String));
                dtOutput.Columns.Add("RMBVALUE", typeof(System.String));
                dtOutput.Columns.Add("MCOSTNET", typeof(System.String));
                dtOutput.Columns.Add("COSTTOT", typeof(System.String));
                dtOutput.Columns.Add("COSTTOTW", typeof(System.String));
                dtOutput.Columns.Add("ACTCOST", typeof(System.String));
                dtOutput.Columns.Add("ACTTOTCOST", typeof(System.String));
                dtOutput.Columns.Add("ACTTOTCOSTW", typeof(System.String));
                dtOutput.Columns.Add("KDKNAME", typeof(System.String));
                dtOutput.Columns.Add("TOTYARN", typeof(System.String));
                dtOutput.Columns.Add("TOTDYE", typeof(System.String));
                dtOutput.Columns.Add("TOTFIN", typeof(System.String));
                dtOutput.Columns.Add("TOTPAKVV", typeof(System.String));
                dtOutput.Columns.Add("TOTOTHER", typeof(System.String));
                dtOutput.Columns.Add("COMMISSION", typeof(System.String));
                dtOutput.Columns.Add("STAFF", typeof(System.String));
                dtOutput.Merge(dtSoruce, false, MissingSchemaAction.Ignore);
                foreach (DataRow row in dtOutput.Rows)
                {
                    row["INVOICE"] = GetGB2312Value(row["INVOICE"].ToString());
                    row["VAABEZ"] = GetGB2312Value(row["VAABEZ"].ToString());
                    row["CONSTRUCTION"] = GetGB2312Value(row["CONSTRUCTION"].ToString());
                    row["KDKNAME"] = GetGB2312Value(row["KDKNAME"].ToString());
                    row["COMMISSION"] = GetGB2312Value(row["COMMISSION"].ToString());
                    row["STAFF"] = GetGB2312Value(row["STAFF"].ToString());
                }
                exAgent.DataTableToExcel(dtOutput, 2, 1);

                int count = dtOutput.Rows.Count;
                exAgent.SetCellValue(1, 1, 1);
                exAgent.BatchConvert2Number(2, 9, count + 1, 30);
                exAgent.BatchConvert2Number(2, 32, count + 1, 36);
                exAgent.SetCellValue(1, 1, "公司");

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
       }
}